var t = getApp(), a = require("../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ a ],
    data: {
        activity_used: 0,
        activity_total: 0,
        activity_point: 0,
        activity_stock: 0,
        dataList: [],
        total_page: 0,
        integral: ""
    },
    onLoad: function(t) {},
    onReady: function() {},
    onShow: function() {
        this._initData(), this._getData();
        try {
            var t = wx.getStorageSync("integral");
            t && (this.setData({
                integral: t
            }), this.data.integral && wx.setNavigationBarTitle({
                title: this.data.integral + "活动"
            }));
        } catch (t) {}
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    _initData: function() {
        this.setData({
            activity_used: 0,
            activity_total: 0,
            activity_point: 0,
            activity_stock: 0,
            dataList: [],
            total_page: 0,
            integral: ""
        });
    },
    _getData: function() {
        var a = this, e = t.getNetAddresss("plugin.point-activity.Frontend.Controllers.page.index");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: this.data.form,
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    var i = e.data;
                    a.setData({
                        activity_used: i.activity_used,
                        activity_total: i.activity_total,
                        activity_point: i.activity_point,
                        activity_stock: i.activity_stock,
                        total_page: i.records.last_page ? i.records.last_page : "",
                        latest_record: i.latest_record
                    }), a.data.total_page || a.setData({
                        total_page: 0
                    }), a.setData({
                        dataList: i.records.data ? i.records.data : []
                    }), wx.setNavigationBarColor({
                        frontColor: "#ffffff",
                        backgroundColor: a.data.themeBaseColor,
                        animation: {
                            duration: 400,
                            timingFunc: "easeIn"
                        }
                    });
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    toIntegralGeneralization: function() {
        wx.navigateTo({
            url: "/packageB/member/IntegralGeneralization/IntegralGeneralization"
        });
    },
    goGetRecord: function() {
        wx.navigateTo({
            url: "/packageB/member/IntegralGetRecord/IntegralGetRecord"
        });
    },
    toIntegralRecord: function(t) {
        var a = t.currentTarget.dataset.activityid;
        wx.navigateTo({
            url: "/packageB/member/IntegralRecord/IntegralRecord?activity_id=" + a
        });
    },
    toIntegralPresent: function(t) {
        var a = t.currentTarget.dataset.activityid;
        wx.navigateTo({
            url: "/packageB/member/IntegralPresent/IntegralPresent?activity_id=" + a
        });
    }
});